<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../Templates/InnerSystemTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="head-title">
        <title>View Discount | Merlion's ERP System</title>
    </ui:define>
    
    <ui:define name="content">
        <h:form>
            <p:dataTable var="discount" value="#{viewDiscountManagerBean.discounts}" 
                         dynamic="true" paginator="true" rows="5" emptyMessage="No discount found in database." selection="#{viewDiscountManagerBean.selectedDiscount}">             
                    <p:column selectionMode="single" />
                    
                    <p:column id="discountId" sortBy="#{discount.discountId}"> 
                        <f:facet name="header"> 
                            <h:outputText value="ID" /> 
                        </f:facet> 
                        <h:outputText value="#{discount.discountId}" /> 
                    </p:column> 
 
                    <p:column id="productType" sortBy="#{discount.productType}"> 
                        <f:facet name="header"> 
                            <h:outputText value="Product Type" /> 
                        </f:facet> 
                        <h:outputText value="#{discount.productType}" /> 
                    </p:column> 
                   
                    <p:column sortBy="#{discount.lowerLimit}"> 
                        <f:facet name="header"> 
                            <h:outputText value="Lower Limit" /> 
                        </f:facet> 
                        <h:outputText value="#{discount.lowerLimit}" /> 
                    </p:column>
            
                    <p:column sortBy="#{discount.higherLimit}"> 
                        <f:facet name="header"> 
                            <h:outputText value="Upper Limit" /> 
                        </f:facet> 
                        <h:outputText value="#{discount.higherLimit}" /> 
                    </p:column>
            
                    <p:column sortBy="#{discount.discountRate}"> 
                        <f:facet name="header"> 
                            <h:outputText value="Discount Rate" /> 
                        </f:facet> 
                        <h:outputText value="#{discount.discountRate}" /> 
                    </p:column>
            
                    <f:facet name="footer">  
                        <p:commandButton value="Edit" actionListener="#{viewDiscountManagerBean.editDiscount}"/>                             
                        <p:commandButton value="Delete" image="ui-icon ui-icon-close" update="display3 display4" onclick="discountDeleteDialog.show()">
                            <f:setPropertyActionListener value="#{discount}" target="#{viewDiscountManagerBean.selectedDiscount}"/>
                        </p:commandButton>
                    </f:facet>
        </p:dataTable>
            
            <p:confirmDialog message="Are you sure to delete the discount?"  
        showEffect="clip" hideEffect="fold" 
        header="Initiating delete process" severity="alert" widgetVar="discountDeleteDialog">  

                <p:commandButton value="Yes" update="messages" oncomplete= "discountDeleteDialog.hide()"  
                                 actionListener="#{viewDiscountManagerBean.deleteDiscount}" />  
                <p:commandButton value="No" onclick="discountDeleteDialog.hide()" type="button" />  
            </p:confirmDialog>
        </h:form>
    </ui:define>

</ui:composition>

